﻿using Microsoft.AspNetCore.Http;
using PetAdoptionShared.Enum;

namespace PetAdoptionShared.Dto;

public record Res<TData>(bool Success, TData? Data, string? Msg=null)
{
    public static Res<TData> Ok(TData data) => new(true, data);
    public static Res<object> Ok() => new(true, null);
    public static Res<object> Fail(string msg = "") => new(false, null, msg);
}
public record class Res(bool Success, object? Data, string? Msg = null)
{
    public static Res Ok(object data) => new(true, data);
    public static Res Ok() => new(true, null);
    public static Res Fail(string msg = "") => new(false, null, msg);
}

public class PetDto
{
    public int Id;
    public string Name=default!;
    public string Image=default!;
    public string Breed = default!;
    public double Price;
}

public class PetDetailDto : PetDto
{
    public bool IsFavorite;
    public string Description = default!;
    public Gender Gender;
    public DateTime DateOfBirth;
    public string GenderDisplay => Gender.ToString();
    public string Age
    {
        get
        {
            var diff = DateTime.Now.Subtract(DateOfBirth);
            var days = diff.Days;
            return days switch
            {
                < 30 => days +" days",
                30 | 31 => "1 Month",
                < 365 => Math.Floor(diff.TotalDays / 30) +" months",
                _ => Math.Floor(diff.TotalDays / 365) + " years"
            };
        }
    }
}